3.1.30 \(\int \sec (c+d x) (a+i a \tan (c+d x))^2 \, dx\) [30]

Optimal. Leaf size=68 \[ \frac {3 a^2 \tanh ^{-1}(\sin (c+d x))}{2 d}+\frac {3 i a^2 \sec (c+d x)}{2 d}+\frac {i \sec (c+d x) \left (a^2+i a^2 \tan (c+d x)\right )}{2 d} \]

[Out]

3/2*a^2*arctanh(sin(d*x+c))/d+3/2*I*a^2*sec(d*x+c)/d+1/2*I*sec(d*x+c)*(a^2+I*a^2*tan(d*x+c))/d

________________________________________________________________________________________

Rubi [A]
time = 0.03, antiderivative size = 68, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, integrand size = 22, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.136, Rules used = {3579, 3567, 3855} \begin {gather*} \frac {3 i a^2 \sec (c+d x)}{2 d}+\frac {3 a^2 \tanh ^{-1}(\sin (c+d x))}{2 d}+\frac {i \sec (c+d x) \left (a^2+i a^2 \tan (c+d x)\right )}{2 d} \end {gather*}

Antiderivative was successfully verified.

[In]

Int[Sec[c + d*x]*(a + I*a*Tan[c + d*x])^2,x]

[Out]

(3*a^2*ArcTanh[Sin[c + d*x]])/(2*d) + (((3*I)/2)*a^2*Sec[c + d*x])/d + ((I/2)*Sec[c + d*x]*(a^2 + I*a^2*Tan[c
+ d*x]))/d

Rule 3567

Int[((d_.)*sec[(e_.) + (f_.)*(x_)])^(m_.)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[b*((d*Sec[
e + f*x])^m/(f*m)), x] + Dist[a, Int[(d*Sec[e + f*x])^m, x], x] /; FreeQ[{a, b, d, e, f, m}, x] && (IntegerQ[2
*m] || NeQ[a^2 + b^2, 0])

Rule 3579

Int[((d_.)*sec[(e_.) + (f_.)*(x_)])^(m_.)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[b*(d*
Sec[e + f*x])^m*((a + b*Tan[e + f*x])^(n - 1)/(f*(m + n - 1))), x] + Dist[a*((m + 2*n - 2)/(m + n - 1)), Int[(
d*Sec[e + f*x])^m*(a + b*Tan[e + f*x])^(n - 1), x], x] /; FreeQ[{a, b, d, e, f, m}, x] && EqQ[a^2 + b^2, 0] &&
 GtQ[n, 0] && NeQ[m + n - 1, 0] && IntegersQ[2*m, 2*n]

Rule 3855

Int[csc[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-ArcTanh[Cos[c + d*x]]/d, x] /; FreeQ[{c, d}, x]

Rubi steps

\begin {align*} \int \sec (c+d x) (a+i a \tan (c+d x))^2 \, dx &=\frac {i \sec (c+d x) \left (a^2+i a^2 \tan (c+d x)\right )}{2 d}+\frac {1}{2} (3 a) \int \sec (c+d x) (a+i a \tan (c+d x)) \, dx\\ &=\frac {3 i a^2 \sec (c+d x)}{2 d}+\frac {i \sec (c+d x) \left (a^2+i a^2 \tan (c+d x)\right )}{2 d}+\frac {1}{2} \left (3 a^2\right ) \int \sec (c+d x) \, dx\\ &=\frac {3 a^2 \tanh ^{-1}(\sin (c+d x))}{2 d}+\frac {3 i a^2 \sec (c+d x)}{2 d}+\frac {i \sec (c+d x) \left (a^2+i a^2 \tan (c+d x)\right )}{2 d}\\ \end {align*}

________________________________________________________________________________________

Mathematica [B] Both result and optimal contain complex but leaf count is larger than twice the leaf count of optimal. \(146\) vs. \(2(68)=136\).
time = 0.82, size = 146, normalized size = 2.15 \begin {gather*} -\frac {a^2 \sec ^2(c+d x) \left (-8 i \cos (c+d x)+3 \log \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )+3 \cos (2 (c+d x)) \left (\log \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )-\log \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )\right )-3 \log \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )+2 \sin (c+d x)\right )}{4 d} \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[Sec[c + d*x]*(a + I*a*Tan[c + d*x])^2,x]

[Out]

-1/4*(a^2*Sec[c + d*x]^2*((-8*I)*Cos[c + d*x] + 3*Log[Cos[(c + d*x)/2] - Sin[(c + d*x)/2]] + 3*Cos[2*(c + d*x)
]*(Log[Cos[(c + d*x)/2] - Sin[(c + d*x)/2]] - Log[Cos[(c + d*x)/2] + Sin[(c + d*x)/2]]) - 3*Log[Cos[(c + d*x)/
2] + Sin[(c + d*x)/2]] + 2*Sin[c + d*x]))/d

________________________________________________________________________________________

Maple [A]
time = 0.14, size = 86, normalized size = 1.26

method result size
derivativedivides \(\frac {-a^{2} \left (\frac {\sin ^{3}\left (d x +c \right )}{2 \cos \left (d x +c \right )^{2}}+\frac {\sin \left (d x +c \right )}{2}-\frac {\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{2}\right )+\frac {2 i a^{2}}{\cos \left (d x +c \right )}+a^{2} \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{d}\) \(86\)
default \(\frac {-a^{2} \left (\frac {\sin ^{3}\left (d x +c \right )}{2 \cos \left (d x +c \right )^{2}}+\frac {\sin \left (d x +c \right )}{2}-\frac {\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{2}\right )+\frac {2 i a^{2}}{\cos \left (d x +c \right )}+a^{2} \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{d}\) \(86\)
risch \(\frac {i a^{2} \left (5 \,{\mathrm e}^{3 i \left (d x +c \right )}+3 \,{\mathrm e}^{i \left (d x +c \right )}\right )}{d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )^{2}}+\frac {3 a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right )}{2 d}-\frac {3 a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right )}{2 d}\) \(89\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(sec(d*x+c)*(a+I*a*tan(d*x+c))^2,x,method=_RETURNVERBOSE)

[Out]

1/d*(-a^2*(1/2*sin(d*x+c)^3/cos(d*x+c)^2+1/2*sin(d*x+c)-1/2*ln(sec(d*x+c)+tan(d*x+c)))+2*I*a^2/cos(d*x+c)+a^2*
ln(sec(d*x+c)+tan(d*x+c)))

________________________________________________________________________________________

Maxima [A]
time = 0.28, size = 83, normalized size = 1.22 \begin {gather*} \frac {a^{2} {\left (\frac {2 \, \sin \left (d x + c\right )}{\sin \left (d x + c\right )^{2} - 1} + \log \left (\sin \left (d x + c\right ) + 1\right ) - \log \left (\sin \left (d x + c\right ) - 1\right )\right )} + 4 \, a^{2} \log \left (\sec \left (d x + c\right ) + \tan \left (d x + c\right )\right ) + \frac {8 i \, a^{2}}{\cos \left (d x + c\right )}}{4 \, d} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sec(d*x+c)*(a+I*a*tan(d*x+c))^2,x, algorithm="maxima")

[Out]

1/4*(a^2*(2*sin(d*x + c)/(sin(d*x + c)^2 - 1) + log(sin(d*x + c) + 1) - log(sin(d*x + c) - 1)) + 4*a^2*log(sec
(d*x + c) + tan(d*x + c)) + 8*I*a^2/cos(d*x + c))/d

________________________________________________________________________________________

Fricas [B] Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 148 vs. \(2 (56) = 112\).
time = 0.38, size = 148, normalized size = 2.18 \begin {gather*} \frac {10 i \, a^{2} e^{\left (3 i \, d x + 3 i \, c\right )} + 6 i \, a^{2} e^{\left (i \, d x + i \, c\right )} + 3 \, {\left (a^{2} e^{\left (4 i \, d x + 4 i \, c\right )} + 2 \, a^{2} e^{\left (2 i \, d x + 2 i \, c\right )} + a^{2}\right )} \log \left (e^{\left (i \, d x + i \, c\right )} + i\right ) - 3 \, {\left (a^{2} e^{\left (4 i \, d x + 4 i \, c\right )} + 2 \, a^{2} e^{\left (2 i \, d x + 2 i \, c\right )} + a^{2}\right )} \log \left (e^{\left (i \, d x + i \, c\right )} - i\right )}{2 \, {\left (d e^{\left (4 i \, d x + 4 i \, c\right )} + 2 \, d e^{\left (2 i \, d x + 2 i \, c\right )} + d\right )}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sec(d*x+c)*(a+I*a*tan(d*x+c))^2,x, algorithm="fricas")

[Out]

1/2*(10*I*a^2*e^(3*I*d*x + 3*I*c) + 6*I*a^2*e^(I*d*x + I*c) + 3*(a^2*e^(4*I*d*x + 4*I*c) + 2*a^2*e^(2*I*d*x +
2*I*c) + a^2)*log(e^(I*d*x + I*c) + I) - 3*(a^2*e^(4*I*d*x + 4*I*c) + 2*a^2*e^(2*I*d*x + 2*I*c) + a^2)*log(e^(
I*d*x + I*c) - I))/(d*e^(4*I*d*x + 4*I*c) + 2*d*e^(2*I*d*x + 2*I*c) + d)

________________________________________________________________________________________

Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} - a^{2} \left (\int \tan ^{2}{\left (c + d x \right )} \sec {\left (c + d x \right )}\, dx + \int \left (- 2 i \tan {\left (c + d x \right )} \sec {\left (c + d x \right )}\right )\, dx + \int \left (- \sec {\left (c + d x \right )}\right )\, dx\right ) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sec(d*x+c)*(a+I*a*tan(d*x+c))**2,x)

[Out]

-a**2*(Integral(tan(c + d*x)**2*sec(c + d*x), x) + Integral(-2*I*tan(c + d*x)*sec(c + d*x), x) + Integral(-sec
(c + d*x), x))

________________________________________________________________________________________

Giac [A]
time = 0.53, size = 107, normalized size = 1.57 \begin {gather*} \frac {3 \, a^{2} \log \left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 1\right ) - 3 \, a^{2} \log \left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 1\right ) - \frac {2 \, {\left (a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} + 4 i \, a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 4 i \, a^{2}\right )}}{{\left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} - 1\right )}^{2}}}{2 \, d} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sec(d*x+c)*(a+I*a*tan(d*x+c))^2,x, algorithm="giac")

[Out]

1/2*(3*a^2*log(tan(1/2*d*x + 1/2*c) + 1) - 3*a^2*log(tan(1/2*d*x + 1/2*c) - 1) - 2*(a^2*tan(1/2*d*x + 1/2*c)^3
 + 4*I*a^2*tan(1/2*d*x + 1/2*c)^2 + a^2*tan(1/2*d*x + 1/2*c) - 4*I*a^2)/(tan(1/2*d*x + 1/2*c)^2 - 1)^2)/d

________________________________________________________________________________________

Mupad [B]
time = 3.82, size = 104, normalized size = 1.53 \begin {gather*} \frac {3\,a^2\,\mathrm {atanh}\left (\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\right )}{d}-\frac {a^2\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^3+a^2\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2\,4{}\mathrm {i}+a^2\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )-a^2\,4{}\mathrm {i}}{d\,\left ({\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^4-2\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2+1\right )} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((a + a*tan(c + d*x)*1i)^2/cos(c + d*x),x)

[Out]

(3*a^2*atanh(tan(c/2 + (d*x)/2)))/d - (a^2*tan(c/2 + (d*x)/2)^2*4i + a^2*tan(c/2 + (d*x)/2)^3 - a^2*4i + a^2*t
an(c/2 + (d*x)/2))/(d*(tan(c/2 + (d*x)/2)^4 - 2*tan(c/2 + (d*x)/2)^2 + 1))

________________________________________________________________________________________